from collections import Counter


def solve(s, t):
    s_dict = Counter(s)
    t_dict = Counter(t)

    sKeyCount = list(s_dict.values())
    tKeyCount = list(t_dict.values())
    tempDict = {}

    for i in range(len(sKeyCount)):
        if sKeyCount[i] != tKeyCount[i]:
            return False

    for i in range(len(s)):
        tempDict[s[i]] = t[i]

    for i in range(len(t)):
        if t[i] != tempDict[s[i]]:
            return False

    return True


if __name__ == "__main__":
    s = "paper"
    t = "title"
    print(solve(s, t))
